package exmpcase;

public class Test2 {
    public static void main(String[] args) {
        String str = "123456789";
        if(!str.matches("[1-9]\\d{0,9}")){
            System.out.println("格式错误");
        }else {
            System.out.println("格式正确");
            int sum = 0;
            for (int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                int num = c - '0';
                sum = sum * 10 + num;
                System.out.println(sum);
            }
        }
    }

}
